<?php

require_once('DataBase.php');

class ContactoDB extends DataBase {

    function ContactoDB() {
        
    }

    function save() {


        $link = $this->connect();
        $sql = "INSERT INTO contacto (nombres,apellidos,rut,mail) VALUES ('$this->nombres','$this->apellidos','$this->rut','$this->mail')";
        $result = mysql_query($sql);
        $this->desconectarse($link);
        if ($result)
            return true;
        else
            return false;
    }

    function getContacto($id) {
        $link = $this->connect();
        $sql = 'SELECT * FROM contacto WHERE id_contacto='.$id;
        $index = mysql_query($sql);
        while ($row = mysql_fetch_row($index)) {
            $i = 0;
            $contacto = new Contacto($row[$i++], $row[$i++], $row[$i++], $row[$i++],$row[$i++]);
        }
        $this->desconectarse($link);
        return $contacto;
    }
    
    

}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>